package com.abapi.pay;

import com.abapi.pay.client.PayTcpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author ldx
 * @Date 2019/9/29 10:32
 * @Description
 * @Version 1.0.0
 */
@Configuration
@EnableConfigurationProperties({AbapiPayProperties.class})
@ConditionalOnProperty(name = "abapi.pay.config.enabled", matchIfMissing = true)
public class PayAutoConfiguration {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    AbapiPayProperties abapiPayProperties;

    @Bean
    public PayTcpClient startTcpService(){
        logger.info("pay start>{}",abapiPayProperties);
        PayTcpClient client = new PayTcpClient(abapiPayProperties);
        client.start();
        return client;
    }

}
